x11: Ignore old XFixesSelectionNotify events
authorJason Crain <jcrain@src.gnome.org>
Sat, 21 Jul 2018 09:17:57 +0000 (04:17 -0500)
committerJason Crain <jcrain@src.gnome.org>
Sat, 21 Jul 2018 20:22:04 +0000 (15:22 -0500)
GtkEntryCompletion can rapidly release and claim ownership of the
primary selection. This generates multiple XFixesSelectionNotify events,
first stating that no one owns the selection, then another stating that
we own the selection. The notification that no one owns the selection
causes GtkEntryCompletion to deselect the text, breaking inline
autocompletion.

This fixes it by ignoring any XFixesSelectionNotify with a timestamp
earlier than our clipboard timestamp.

Fixes #14

gdk/x11/gdkclipboard-x11.c

index d2d81e0aea9a6e061b0aefede29d72efca626b54..55d0440e1ec739060990979dec35cdc6b2679d34 100644 (file)
@@ -491,6 +491,14 @@ gdk_x11_clipboard_xevent (GdkDisplay   *display,
           if (sn->selection != cb->xselection)
             return FALSE;
 
+          if (sn->selection_timestamp < cb->timestamp)
+            {
+              GDK_DISPLAY_NOTE (display, CLIPBOARD,
+                        g_printerr ("%s: Ignoring XFixesSelectionNotify with too old timestamp (%lu vs %lu)\n",
+                                    cb->selection, sn->selection_timestamp, cb->timestamp));
+              return FALSE;
+            }
+
           if (sn->owner == GDK_X11_DISPLAY (display)->leader_window)
             {
               GDK_DISPLAY_NOTE (display, CLIPBOARD,